//
//  TopicsTableViewCell.m
//  FreeTrip
//
//  Created by 352324497@qq.com on 15/11/24.
//  Copyright © 2015年 邓芮. All rights reserved.
//

#import "TopicsTableViewCell.h"

@implementation TopicsTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle = NO;
        
        CGFloat height = (KScreenWidth - 10 * 2 ) / 1600 * 1060;
        self.backgroundImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10 * KScreenWidth / 375, 10 * KScreenWidth / 375, KScreenWidth - 10 * 2, height)];
        [self.contentView addSubview:_backgroundImageView];
        
        UIView *coverView = [[UIView alloc]initWithFrame:self.backgroundImageView.frame];
        coverView.backgroundColor = [UIColor blackColor];
        coverView.alpha = 0.2;
        [self.contentView addSubview:coverView];
        
        CGFloat x = 30 * KScreenWidth / 375;
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, height / 6 * 4, (KScreenWidth - x * 2), height / 6)];
        self.nameLabel.textColor = [UIColor whiteColor];
        self.nameLabel.font = [UIFont boldSystemFontOfSize:26];
        [self.contentView addSubview:_nameLabel];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, height / 6 * 5, (KScreenWidth - x * 2), height / 6)];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:20 * KScreenWidth / 375];
        [self.contentView addSubview:_titleLabel];
    }
    return self;
}

-(void)setModel:(BookTopicsModel *)model
{
    _model = model;
    [self.backgroundImageView sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.nameLabel.text = model.name;
    self.titleLabel.text = model.title;
}
+(CGFloat)heightForCell
{
    return (KScreenWidth - 10 * 2 ) / 1600 * 1060 + 10;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
